#include "MetaDataManager.h"

MetadataManager::MetadataManager(PDDoc pdd)
{
	_pdDoc = pdd;
	m_namespaceName = ASTextFromPDText("http://ns.adobe.com/pdf/1.3/");
	m_namespacePrefix = ASTextFromPDText("pdf");
}

MetadataManager::~MetadataManager(void)
{
}

//------------------------------------------------------------------------------------

ASText MetadataManager::GetMeta(ASText key)
{
  ASText MetaPropText = PDDocGetXAPMetadataProperty (_pdDoc, m_namespaceName, key);
  
  return MetaPropText;
}

//------------------------------------------------------------------------------------

bool MetadataManager::SetMeta(ASText key, ASText value)
{
	if(_pdDoc == NULL) return false;
  
DURING
	PDDocSetXAPMetadataProperty (_pdDoc,
                                    m_namespaceName,
                                    m_namespacePrefix,
                                    key, 
                                    value);
HANDLER
	char buf[256];
	AVAlertNote(ASGetErrorString(ERRORCODE, buf, 255));
	return false;
END_HANDLER
	return true;
}
